def test():
    tfilename = "../bak/24.tar"
    
    import tarfile
    print tarfile.is_tarfile(tfilename)
    tar = tarfile.open(tfilename, "r")
    file_list = tar.getmembers()
    
    print tar.extractfile(file_list[0]).read()
    
    print filter(lambda x:x.isfile() and x.name.startswith("set/"), file_list)
    
    import imghdr
    print imghdr.what('test.py', tar.extractfile(file_list[5]).read())
    tar.close()

def main():
    p="c:/geo/tbgeo.h"
    import os    
    print os.path.split(p)
    
    f = open(p, 'r')
    print f.name
    f.close()
    
if __name__ == '__main__':
    main()
